package com.example.mobile2021606145zbq0330;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText edtMainAccount;
    private EditText edtMianPsw;
    private Button btnMainAdd;
    private Button btnMainRec;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        Intent intent1=new Intent(MainActivity.this,Tip1Activity.class);

        btnMainAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String account = edtMainAccount.getText().toString();
                String passwork = edtMianPsw.getText().toString();

                if (account.length() == 0) {
                    Log.i("登录", "请输入用户名");


                } else if (passwork.length() == 0) {
                    Log.i("登录", "请输入密码");
                } else {


                    if (account.equals("admin") & passwork.equals("123456")) {
                        Log.i("登录", "登录成功");
                    } else {
                        Log.i("登录", "登录失败");
                    }
                    edtMainAccount.setText(null);
                    edtMianPsw.setText(null);
                }


            }
        });
        btnMainRec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                edtMainAccount.setText(null);
                edtMianPsw.setText(null);

            }
        });

        }




    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        edtMainAccount = (EditText) findViewById(R.id.edt_main_account);
        edtMianPsw = (EditText) findViewById(R.id.edt_mian_psw);
        btnMainAdd = (Button) findViewById(R.id.btn_main_add);
        btnMainRec = (Button) findViewById(R.id.btn_main_rec);
    }

      }
